package Animal_And_Interface;

public class Test{
    public static void testEat(Animal a){
        a.eatFood();
    }
    public static void testRun(IRunning iRunning){
        iRunning.run();
    }
    public static void testFly(IFlying iFlying){
        iFlying.fly();
    }
    public static void testSwim(ISwimming iSwimming){
        iSwimming.swim();
    }
    public void act(IRunning iRunning){
        iRunning.run();
    }
    public static void main(String[] args) {
        Animal a = new Panda("熊猫");
        Animal b = new Dog("小狗");
        Animal c = new Bird("小鸟");
        Animal d = new Fish("小鱼");

        a.eatFood();
        b.eatFood();
        c.eatFood();
        d.eatFood();

        a.drinkWater();
        b.drinkWater();
        c.drinkWater();
        d.drinkWater();

        testEat(a);
        testEat(b);
        testEat(c);
        testEat(d);

        IRunning panda1 = new Panda("熊猫");
        IRunning dog1 = new Dog("小狗");
        IRunning bird1 = new Bird("小鸟");
        //Animal_And_Interface.IRunning fish1 = new Animal_And_Interface.Fish("小鱼");
        testRun(panda1);
        testRun(dog1);
        testRun(bird1);

        //Animal_And_Interface.IFlying panda2 = new Animal_And_Interface.Panda("熊猫");
        //Animal_And_Interface.IFlying dog2 = new Animal_And_Interface.Dog("小狗");
        IFlying bird2 = new Bird("小鸟");
        //Animal_And_Interface.IFlying fish2 = new Animal_And_Interface.Fish("小鱼");
        testFly(bird2);

        //Animal_And_Interface.ISwimming panda3 = new Animal_And_Interface.Panda("熊猫");
        ISwimming dog3 = new Dog("小狗");
        //Animal_And_Interface.ISwimming bird3 = new Animal_And_Interface.Bird("小鸟");
        ISwimming fish3 = new Fish("小鱼");
        testSwim(dog3);
        testSwim(fish3);

        Test t = new Test();
        t.act(panda1);
        t.act(dog1);
        t.act(bird1);

//        Animal_And_Interface.Animal a = new Animal_And_Interface.Bird("小鸟");
//        ((Animal_And_Interface.Bird) a).fly();
//
//        Animal_And_Interface.Animal a2 = new Animal_And_Interface.Dog("狗子");
//        if(a2 instanceof Animal_And_Interface.Bird){
//            ((Animal_And_Interface.Bird)a2).fly();
//        }else{
//            System.out.println("a2是狗子转型过来的，不能飞");
//        }

//        Animal_And_Interface.Dog d = new Animal_And_Interface.Dog("狗子");
//        Animal_And_Interface.Animal.play(d);

//        Animal_And_Interface.Animal a1 = new Animal_And_Interface.Dog("狗子");
//        Animal_And_Interface.Animal a2 = new Animal_And_Interface.Panda("熊猫");


    }
}
